# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# $Id: admin.py 129 2008-08-15 15:20:26Z semente $
# ----------------------------------------------------------------------------
#
#  Copyright (c) 2008 Guilherme Mesquita Gondim
#
#  This file is part of django-diario.
#
#  django-tube is free software under terms of the GNU General
#  Public License version 3 (GPLv3) as published by the Free Software
#  Foundation. See the file README for copying conditions.
#

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from diario.models import Entry
from diario.settings import HAS_TAG_SUPPORT

if HAS_TAG_SUPPORT:
    TAG_FIELD = ['tags']
else:
    TAG_FIELD = []

class EntryAdmin(admin.ModelAdmin):
    date_hierarchy = 'pub_date'
    fieldsets = (
        (None, {
            'fields': ['title', 'slug', 'pub_date', 'body_source'] + TAG_FIELD
        }),
        (_('Status'), {
            'fields': ('is_draft', 'publish_on')
        }),
        (_('Discussion'), {
            'fields': ('enable_comments',)
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('markup',),
        })
    )
    list_display  = ('title', 'pub_date', 'is_draft', 'enable_comments')
    list_filter   = ('is_draft', 'publish_on', 'enable_comments', 'markup')
    prepopulated_fields = {'slug': ('title',)}
    radio_fields = {'markup': admin.VERTICAL}
    search_fields = ['title', 'slug', 'body']

admin.site.register(Entry, EntryAdmin)
